package com.lin.rmi;

import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

/**
 * @ClassName RmiServer
 * @Description
 * @Author lin
 * @Date 2022/7/6 上午12:25
 * @Version V1.0
 */
public class RmiServer {
    public static void main(String[] args) {
        try {
            Registry registry = LocateRegistry.getRegistry("127.0.0.1", 8000); //获取注册中心引用
            IRemote remoteHello = (IRemote) registry.lookup("name"); //获取RemoteHello服务
            System.out.println(remoteHello.sayHello("tom")); //调用远程方法
        } catch (RemoteException | NotBoundException e) {
            e.printStackTrace();
        }
    }
}
